import {isObject} from './common';
import {get,post,put,remove} from '@/plugins/axios';
import api from './interfaceApi';
// post('/wap/v1/user/entinfo',{
//     cityCode: 130600,
//     cityName: "保定市",
//     countyCode: "130633",
//     countyName: "易县",
//     creditCode: "12314123123",
//     entAddress: "象牙山896号",
//     entLinkPhone: "",
//     entLinkUser: "",
//     entName: "阿里七七",
//     finanLimit: "",
//     legalRepre: "王大拿",
//     legalRepreIden: "1306261905509088970",
//     legalReprePhone: "18232532098",
//     linkUserSex: "0",
//     postCode: "",
//     proCode: 130000,
//     proName: "河北省",
//     registCost: "500"
// }).then(res=>{
//     console.log(res)
// })
class Inter{
    constructor(urlArr,options){
        if(!isObject(options)){
            throw Error('options 必须是一个对象')
        }
        this.urlAppend=typeof urlArr == "string" ? urlArr : urlArr.join('/');
        this.options=options;
    }
    //地区接口
    area(){
        return get(api.area.getArea+this.urlAppend,this.options)//图片码
    }
    //登录注册
    getPicCode(){
        return get(api.signIn.getPicCode+this.urlAppend,this.options)//图片码
    }
    getMessageCode(){
        return get(api.signIn.getMessageCode+this.urlAppend,this.options)//短信验证码
    }
    register(){
        return post(api.signIn.register+this.urlAppend,this.options)//注册
    }
    pwdLogin(){
        return post(api.signIn.pwdLogin+this.urlAppend,this.options)//密码登录
    }
    msgLogin(){
        return post(api.signIn.msgLogin+this.urlAppend,this.options)//短信登录
    }
    searchRegionCode(){
        return get(api.signIn.searchRegionCode+this.urlAppend,this.options)//查询地区码
    }
    getReadInfo(){
        return get(api.signIn.getReadInfo+this.urlAppend,this.options)//服务协议/隐私声明/关于我们
    }
    //首页
    myHonePagegetStatistic(){ }

    getpolicyInfoList(){
        return get(api.home.getpolicyInfoList+this.urlAppend,this.options)  //首页政策资讯列表
    }
    getswiperPics(){
        return get(api.home.getswiperPics+this.urlAppend,this.options) //首页轮播图加载
    }
    getHotProducts(){
        return get(api.home.getHotProducts+this.urlAppend,this.options) //首页热门产品加载
    }
    infoAggregation(){
        return get(api.home.infoAggregation+this.urlAppend,this.options) //首页信息汇总
    }
    getTradeInfo(){
        return get(api.home.getTradeInfo+this.urlAppend,this.options) //首页交易动态查询
    }
    //我的首页
    getStatistic(){
        return get(api.myHonePage.getStatistic+this.urlAppend,this.options)         //用户数据统计
    }
    //融资
    loanpostPublish(){
        return post(api.myAploanply.postPublish+this.urlAppend,this.options)           //非定向
    }          
    loanpostBuy(){
        return post(api.loan.postBuy+this.urlAppend,this.options)          //定向
    }                   
    loangetDict(){
        return get(api.loan.getDict+this.urlAppend,this.options)         //查询抵押方式
    }                         
    // 我的申请
    myApplygetFinanals(){
        return get(api.myApply.getFinanals+this.urlAppend,this.options)             //定向/非定向申请列表
    }    
    myApplygetProducts(){
        return get(api.myApply.getProducts+this.urlAppend,this.options)             //查询用户当前购买所有产品
    }                           
    myApplygetDetail(){
        return get(api.myApply.getDetail+this.urlAppend,this.options)               //申请详情（融资申请-用户已申请请求详情）
    }   
    //资讯  
    getInfogetInfos(){
        return get(api.info.getInfos+this.urlAppend,this.options)                //咨询列表(政策)
    }                         
    getInfopostInfo(){
        return post(api.info.postInfo+this.urlAppend,this.options)                //咨询详情
    }                          
    getInfopostCollectInfo(){
        return post(api.info.postCollectInfo+this.urlAppend,this.options)               //添加资讯收藏
    }      
    getInfodeleteCollectInfo(){
        return remove(api.info.deleteCollectInfo+this.urlAppend,this.options)                //删除资讯收藏
    }     
    //产品
    getProductsgetProducts(){
        return get(api.product.getProducts+this.urlAppend,this.options)               //列表展示
    }                   
    getProductsgetProduct(){
        return get(api.product.getProduct+this.urlAppend,this.options)                //查看产品详情
    }                       
    getProductspostProduct(){
        return post(api.product.postProduct+this.urlAppend,this.options)               //用户收藏产品
    }         
    getProductsdeleteProduct(){
        return remove(api.product.deleteProduct+this.urlAppend,this.options)             //用户收藏产品取消
    }      
    getProductsgetOrg(){
        return get(api.product.getOrg+this.urlAppend,this.options)                    //金融机构搜索条件
    }                               

    //我的收藏
    myCollectgetProduct(){
        return get(api.myCollect.getProduct+this.urlAppend,this.options)            //产品收藏列表（首页-获取用户收藏资讯信息）
    }    
    myCollectpostProduct (){
        return post(api.myCollect.postProduct+this.urlAppend,this.options)          //用户收藏产品
    }                  
    myCollectdeleteProduct(){
        return remove(api.myCollect.deleteProduct+this.urlAppend,this.options)      //用户收藏产品取消
    }    
    myCollectgetInfo(){ 
        return get(api.myCollect.getInfo+this.urlAppend,this.options)               //资讯收藏列表（首页-获取用户收藏资讯信息）
    }   
    myCollectpostInfo(){
        return post(api.myCollect.postInfo+this.urlAppend,this.options)             //添加资讯收藏
    }     
    myCollectdeleteInfo(){
        return remove(api.myCollect.deleteInfo+this.urlAppend,this.options)         //删除资讯收藏
    }     

    //企业信息
    companyMsggetEntinfo(){
        return get(api.companyMsg.getEntinfo+this.urlAppend,this.options)           //根据手机号查询企业列表
    }    
    companyMsgpostEntinfo(){
        return post(api.companyMsg.postEntinfo+this.urlAppend,this.options)         //添加企业信息
    }                            
    companyMsgputEntinfo(){
        return put(api.companyMsg.putEntinfo+this.urlAppend,this.options)            //修改企业信息
    }                            
    companyMsggetEntinfoByCreditCode(){
        return get(api.companyMsg.getEntinfoByCreditCode+this.urlAppend,this.options)//根据企业信用代码查询
    }     

    //我的足迹
    myFootprintgetFootmarks(){
        return get(api.myFootprint.getFootmarks+this.urlAppend,this.options)        //足迹列表
    }   
    
    //修改密码
    modifyPWputUser(){ 
        return put(api.modifyPW.putUser+this.urlAppend,this.options)                //修改密码
    }  

}
function axiosMd(methods,arr,options){
    let inter=new Inter(arr,options)
    if(!inter[methods]){
        throw Error(`${methods}未定义`)
    }else{
       return inter[methods]()
    }
}
export default axiosMd